/** # feeds信息流 模块 */
import { messages } from '@/api/message';
import * as types from '../mutation-types';

// initial state
const state = {
  messages: [],
  message: null,
};

// getters
const getters = {
  getMessages: state => state.messages,
  getMessage: state => state.message,
};

// actions
const actions = {
  messages({ commit }) {
    const params = {
      clientId: 'e2b6abfc-3576-4fe7-9f69-1f647169a827',
      clientSecret: 'e24e45c9-a7bc-4248-be78-17b32bea1544',
    };
    messages(params)
    .then(data => commit(types.FETCH_MESSAGES, data));
  },
};

// mutations
const mutations = {
  [types.FETCH_MESSAGES](state, { data }) {
    // eslint-disable-next-line
    state.messages = data;
  },
};


export default {
  state,
  getters,
  actions,
  mutations,
};
